package com.yyh.dequetest;

import java.util.Objects;

//公民信息类
public class Citizen {
    //属性
    // 姓名
    private String name;
    // 身份证号码
    private String idNumber;
    //性别
    private String gender;
    //地址
    private String address;
    //无参构造方法
    public Citizen() {
    }
    //有参构造方法
    public Citizen(String name, String idNumber, String gender, String address) {
        this.name = name;
        this.idNumber = idNumber;
        this.gender = gender;
        this.address = address;
    }
    //getter 和 setter 方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIdNumber() {
        return idNumber;
    }

    public void setIdNumber(String idNumber) {
        this.idNumber = idNumber;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }
    //重写equals和hashCode方法
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Citizen citizen = (Citizen) o;
        return gender == citizen.gender && Objects.equals(name, citizen.name) && Objects.equals(idNumber, citizen.idNumber) && Objects.equals(address, citizen.address);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, idNumber, gender, address);
    }
    //重写toString方法
    @Override
    public String toString() {
        return "Citizen{" +
                "name='" + name + '\'' +
                ", idNumber='" + idNumber + '\'' +
                ", gender=" + gender +
                ", address='" + address + '\'' +
                '}';
    }
}
